package com.example.mydemo.response;

import com.example.mydemo.dto.DTO;
import com.example.mydemo.entity.Test;
import lombok.Data;
import org.springframework.http.HttpStatus;

@Data
public class Response <T>{
    private boolean status;
    private String code;
    private T data;
    private String message;
    public static <S> Response<S> newsuccess(S data){
        Response<S> success = new Response();
        success.setStatus(true);
        success.setCode(String.valueOf(HttpStatus.OK.value()));
        success.setData(data);
        success.setMessage("success");
        return success;
    }
    public static <F> Response<F> newfail(String errormessage){
        Response<F> fail = new Response();
        fail.setStatus(false);
        fail.setCode(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()));
        fail.setMessage(errormessage);
        return fail;
    }
}
